package day617parameter;

public class Demo03 {
    public static void main(String[] args) {
        Demo03 d = new Demo03();
        User user = new User();
        user.setName("张三");
        user.setNum(18);
        System.out.println("在没有调用pass方法之前的名字" + user.toString());
        d.pass(user);
        System.out.println("在调用方法pass之后的名字" + user.toString());
    }
    public void pass(User user){
        user.setName("李四");
        System.out.println("pass方法中的名字是" + user.toString());
    }

}
class User{
    private String name;
    private int num;

    public User() {
    }

    public User(String name, int num) {
        this.name = name;
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", num=" + num +
                '}';
    }
}